package com.home766.template.directive;

import com.home766.entity.Cases;
import com.home766.service.CasesService;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import net.biz.template.directive.BaseDirective;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@Component("casesListDirective")
public class CasesListDirective extends BaseDirective {
	@Resource(name = "casesServiceImpl")
	private CasesService casesService;
	/** 变量名称 */
	private static final String VARIABLE_NAME = "cases";

	@Override
	public void execute(Environment env, Map arg1, TemplateModel[] loopVars,
                        TemplateDirectiveBody body) throws TemplateException, IOException {
		// TODO Auto-generated method stub
		List<Cases> list = casesService.getCasesList();
		setLocalVariable(VARIABLE_NAME, list, env, body);
	}
}
